package com.igame.Service.impl;

import com.igame.Service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service

public class CodeServiceImpl implements CodeService {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @Override
    public void setCode(String key, String value) {
        redisTemplate.opsForValue().set(key,value,3, TimeUnit.MINUTES);
    }

    @Override
    public String getCode(String key) {
        return redisTemplate.opsForValue().get(key);
    }
}
